package za.ac.cput.arrowgame.app.facade;

import org.springframework.context.ApplicationContext;
import za.ac.cput.arrowgame.app.config.GetContext;
import za.ac.cput.arrowgame.presentation.desktop.message.UserMessageService;
import za.ac.cput.arrowgame.service.movearrow.MoveArrowService;
import za.ac.cput.arrowgame.service.requesthandler.HandleMove;
import za.ac.cput.arrowgame.service.requesthandler.HandleTurn;
import za.ac.cput.arrowgame.service.requesthandler.HandlerSetup;
import za.ac.cput.arrowgame.service.trunarrow.TrunArrowService;
import za.ac.cput.arrowgame.service.validation.ValidateMove;

/**
 *
 * @author Lance
 */
public class Facade {

    private final static ApplicationContext APPLICATION_CONTEXT = GetContext.getApplicationContext();
    private TrunArrowService turnArrowService;
    private MoveArrowService moveArrowService;
    private UserMessageService userMessageService;
    private ValidateMove validateMove;
    private HandlerSetup handlerSetup;
    private HandleMove handlerMove;
    private HandleTurn handlerTurn;

    private Facade() {
    }

    public static Facade getInstance() {
        return FacadeHolder.INSTANCE;
    }

    public MoveArrowService getMoveArrowService() {
        moveArrowService = (MoveArrowService) APPLICATION_CONTEXT.getBean("moveArrowService");
        return moveArrowService;
    }

    private static class FacadeHolder {
        private static final Facade INSTANCE = new Facade();
    }
  
    public HandleMove getHandleMove() {
        handlerMove = (HandleMove) APPLICATION_CONTEXT.getBean("handleMove");
        return handlerMove;
    }

    public HandleTurn getHandleTurn() {
        handlerTurn = (HandleTurn) APPLICATION_CONTEXT.getBean("handleTurn");
        return handlerTurn;
    }

    public UserMessageService getUserMessageService() {
        userMessageService = (UserMessageService) APPLICATION_CONTEXT.getBean("userMessageService");
        return userMessageService;
    }

    public TrunArrowService getTurnArrowService() {
        turnArrowService = (TrunArrowService) APPLICATION_CONTEXT.getBean("trunArrowService");
        return turnArrowService;
    }

    public HandlerSetup getHandlerSetup() {
        handlerSetup = (HandlerSetup) APPLICATION_CONTEXT.getBean("handlerSetup");
        return handlerSetup;
    }
    
    public ValidateMove getValidateMove() {
        validateMove = (ValidateMove) APPLICATION_CONTEXT.getBean("validateMove");
        return validateMove;
    }
}
